@extends('layouts.admin.application')

@section('css')
    <link rel="stylesheet" href="/ace/assets/css/daterangepicker.css">
@endsection

@section('content')
    <div class="main-content">
        <div class="col-xs-12">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="#">首页</a></li>
                    <li>订单管理</li>
                </ul>
            </div>

            @include('layouts.partials._flash')

            <div class="table-responsive">
                <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                    <div class="row">
                        <form>
                            <div class="col-sm-10">
                                <div class="dataTables_filter" id="sample-table-2_filter">
                                    <label><input type="text" name="id" value="{{Request::input('id')}}"
                                                  aria-controls="sample-table-2"
                                                  placeholder="按订单号">
                                    </label>
                                    <label><input type="text" name="customer_id" value="{{Request::input('customer_id')}}"
                                                  aria-controls="sample-table-2"
                                                  placeholder="按会员编号">
                                    </label>
                                    {{--<label><input type="text" name="total_price" value="{{Request::input('total_price')}}"--}}
                                                  {{--aria-controls="sample-table-2"--}}
                                                  {{--placeholder="订单金额(eg:>100)">--}}
                                    {{--</label>--}}
                                    <label>
                                        <select class="dataTables_filter" name="status" style="width: 180px;">
                                            <option value="-1">订单状态</option>
                                            @foreach ($order_status as $key=>$value)
                                                <option value="{{ $key }}" @if($key == Request::input('status')) selected @endif>
                                                    {{ $value }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </label>
                                    <label><input type="text" name="created_at" id="created_at"
                                                        aria-controls="sample-table-2" style="width: 174px;"
                                                        placeholder="选择下单时间"
                                                        value="{{ Request::input('created_at') }}">
                                    </label>
                                    <label>
                                        <button type="submit" class="btn btn-xs btn-info" id="search">确定</button>
                                        <a href="{{route('shop.order.index')}}" class="btn btn-xs btn-default">重置</a>
                                    </label>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="row">
                        <div class="order-list-box">
                            <ul class="order-list">

                                @foreach($orders as $order)
                                    <li class="uc-order-item {{order_color($order->status)}}">
                                        <div class="order-detail">
                                            <div class="order-summary">
                                                <div class="order-status">{{order_status($order->status)}}</div>
                                            </div>
                                            <table class="order-detail-table">
                                                <thead>
                                                <tr>
                                                    <th class="col-main">
                                                        <p class="caption-info">{{$order->created_at}}
                                                            <span class="sep">|</span>
                                                            {{$order->address->name}}
                                                            (<a href="tel:{{$order->address->tel}}">{{$order->address->tel}}</a>)
                                                            <span class="sep">|</span>
                                                            订单号：<a href="//order.mi.com/user/orderView/1150426350013010">{{$order->id}}</a>
                                                            {{--<span class="sep">|</span>在线支付--}}
                                                        </p>
                                                    </th>
                                                    <th class="col-sub">
                                                        <p class="caption-price">订单金额：
                                                            <span class="num">{{doubleval($order->total_price)}}</span>元
                                                        </p>
                                                    </th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <tr>
                                                    <td class="order-items">
                                                        <ul class="goods-list">
                                                            @foreach($order->order_goods as $item)
                                                            <li>
                                                                <div class="figure figure-thumb">
                                                                    <a href="#" target="_blank">
                                                                        <img src="{{$item->good['image']}}"
                                                                             class="thumb"
                                                                             width="80" height="80"
                                                                             alt="{{$item->good['name']}}">
                                                                    </a>
                                                                </div>
                                                                <p class="name">
                                                                    <a href="#"
                                                                       target="_blank">{{$item->good['name']}}</a>
                                                                </p>
                                                                <p class="price">{{doubleval($item->good['price'])}}
                                                                    元
                                                                    × {{$item->num}}</p>
                                                            </li>
                                                            @endforeach
                                                        </ul>
                                                    </td>
                                                    <td class="order-actions">
                                                        <a href="{{route('shop.order.show', $order->id)}}" class="btn btn-small btn-line-gray">订单详情</a>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </li>
                                @endforeach

                            </ul>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">共 {{$orders->total()}} 条记录</div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_bootstrap">
                                <ul class="pagination">
                                    {{ $orders->appends(Request::all())->links() }}
                                </ul>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="/ace/assets/js/date-time/daterangepicker.min.js"></script>
    <script src="/ace/assets/js/date-time/moment.min.js"></script>
    <script>
        $(function () {
            //时间插件
            $('#created_at').daterangepicker({
                "locale": {
                    "applyLabel": "确定",
                    "cancelLabel": "取消"
                }
            });

        });
    </script>
@endsection
